package edu.hhu.wifispark.task;

import java.util.Date;
import java.util.List;

import edu.hhu.wifispark.entry.Record;
import edu.hhu.wifispark.task.sparktask.CustomerTask;
import edu.hhu.wifispark.util.DateUtil;

public class ObtainCustomer {
	public void start(){
		long nowtime = new Date().getTime();//当前时间
		long endtime = DateUtil.getHour(nowtime);//当前时间的小时整数
		long starttime = endtime -3600000;//当前小时前一个小时
		List<Record> recordsInfo = Record.dao.findCustomerInfo(starttime,endtime);
		List<Record> recordsPeri = Record.dao.FindPeriod(endtime);
		if(recordsInfo == null || recordsInfo.size() == 0 || recordsPeri == null || recordsPeri.size() == 0){
			System.out.println("record is NULL");
			return;
		}
		CustomerTask cCustTask = new CustomerTask(starttime, endtime);
		cCustTask.setRecords(recordsInfo,recordsPeri);
		cCustTask.start();
		try {
			cCustTask.join();
		} catch (InterruptedException e) {
			// TODO: handle exception
		}
	}
}
